package com.myk.game.gobangchess.signs;

import com.myk.game.gobangchess.Sign;

import java.util.ArrayList;
import java.util.List;

/**
 * 包围环绕标记，特点是可以方便实现各种奇形和镂空的背景标记
 */
public class AroundSign extends Sign {

    private final List<Integer> indexes; //包含的格子范围
    private final String bgColor; //背景颜色
    private final String edColor; //边框颜色 （边框是针对一整个整体的）

    private final float size; //边框粗细比例

    public AroundSign(int index, String bgColor, String edColor, float size) {
        this.indexes = new ArrayList<>();
        this.indexes.add(index);
        this.bgColor = bgColor;
        this.edColor = edColor;
        this.size = size;
    }

    public AroundSign(List<Integer> indexes, String bgColor, String edColor, float size) {
        this.indexes = indexes;
        this.bgColor = bgColor;
        this.edColor = edColor;
        this.size = size;
    }

    @Override
    public String getSignInfo() {
        return type + "," + idsToStr() + "," + bgColor + "," + edColor + "," + size;
    }

    private String idsToStr() {
        StringBuilder str = new StringBuilder();
        for (int index : indexes) {
            str.append(index).append("a");
        }
        str.deleteCharAt(str.length() - 1);
        return str.toString();
    }
}
